Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type issues when using createStore in TS #2836

Closed
motistudio opened this issue Nov 24, 2024 · 0 comments
Closed

Type issues when using createStore in TS #2836

motistudio opened this issue Nov 24, 2024 · 0 comments

Comments

@motistudio
Copy link

Hi

I've noticed a type issue when using createStore in a TS environment.
Whenever it's used, the following error appears:

Exported variable 'store' has or is using name 'AtomState' from external module ".../node_modules/jotai/esm/vanilla/store" but cannot be named

TS config

I think it can be fixed by tweeking the module & moduleResolution, but that's not possible for every project.
In my case it's:

{
  "compilerOptions": {
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,
    "jsx": "react-jsx",
    "strict": true,
  }
}

Solution

The solution is to just export the Store type, allowing the type "to be named".
I think it's useful anyhow, since users who use createStore might need to describe it as a type as well.

A wider solution would be to not use the export ... from '...' syntax, it seems that it's the primary case of this specific error across different packages.

--

Thank you!
Loves this library

@pmndrs pmndrs locked and limited conversation to collaborators Nov 25, 2024
@dai-shi dai-shi converted this issue into discussion #2837 Nov 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant